package edu.gxnu.cetcdemo.controller;

import edu.gxnu.cetcdemo.pojo.Reserve;
import edu.gxnu.cetcdemo.service.ReserveService;
import edu.gxnu.cetcdemo.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class ReserveController {

    @Autowired
    private ReserveService reserveService;
    @PostMapping("/reserve")
    @ApiOperation(value = "预约机房接口")
    public Result post(@RequestBody Reserve reserve){
        return reserveService.post(reserve);
    }

    @GetMapping("/reserve")
    @ApiOperation(value = "查询预约记录接口")
    public Result get(){
        return reserveService.get();
    }


    @PutMapping("/reserve/manager")
    @ApiOperation(value = "批准预约接口")
    public Result agree(@RequestBody Map<String,Object> map){
        return reserveService.agree(map);
    }

    @GetMapping("/reserve/user/{id}")
    @ApiOperation(value = "用户查询自己的预约记录")
    public Result userown(@PathVariable Integer id){
        return reserveService.userOwn(id);
    }

    @PutMapping("/reserve/user/{id}")
    @ApiOperation(value = "用户取消预约")
    public Result cancel(@PathVariable Integer id) {return reserveService.cancel(id);}

}
